package com.yunding.house.service.impl;

import com.jfinal.kit.Ret;
import com.yunding.house.mapper.PhonecodeMapper;
import com.yunding.house.pojo.Phonecode;
import com.yunding.house.service.PhonecodeService;
import com.yunding.house.utils.R;
import com.yunding.house.utils.SendCode;
import com.yunding.house.utils.StatusCode;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class PhonecodeServiceImpl implements PhonecodeService {

    @Autowired
    private PhonecodeMapper phonecodeMapper;

    /**
     * 根据用户phone查找出电话号码是否存在
     *
     * @param phone
     * @return
     */
    public Phonecode IsSendCodephoneInfo(String phone) {

        return phonecodeMapper.selectByphone(phone);
    }

    /**
     * 更新
     *
     * @param phonecode@return
     */
    public R update(Phonecode phonecode) {
        if(phonecode==null){
            return new R(false, StatusCode.PARAM_ERROR, "修改失败");
        }
        int n = phonecodeMapper.updateById(phonecode);
        return new R(true, StatusCode.SUCCESS, "修改成功",n);
    }

    /**
     * 保存
     * @param phonecode@return
     */
    public boolean save(Phonecode phonecode) {
        return phonecodeMapper.insert(phonecode)>=1? true : false;
    }


}
